from system.object import Object
from system.eventServer import eventServer

class GaTest(Object):
    def __init__(self, parent, type = None, name = None):
        Object.__init__(self,parent,type,name)
        
        self.ga = self.addChild("ai.ga")
        
        eventServer.register("evaluateIndividual",self.evaluateIndividual)
        
        eventServer.pull("startEvolution",{'seed':1})
        
    def evaluateIndividual(self, cmd, args):
        fit = sum(args['ind'])
        #print "eval", args['gen'], args['id'], fit
        eventServer.netPull('returnFitness',{'id':args['id'],'fitness':fit})
